package agents;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import env.City;
import env.Move;
import env.Road;
import env.World;

public class Human implements Agent {
	private World world;
	private City current;
	private City goal;
	private boolean done;
	public Human(World world, City init, City goal) {
		this.goal = goal;
		this.current = init;
		this.world = world;
		done =false;
	}

	@Override
	public Move calcMove() {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		System.out.print("type name of adjecent city you to go to:");
		try {
			line = br.readLine();
			City dest = world.getCityByName(line);
			if(dest== null)
				{
				System.out.print("no such city :"+line);
				return null;
				}
			Road road =  world.getRoadBetweenCities(current, dest);
			if (road == null)
				{
				System.out.print("no road from "+current.getName()+"to"+line);
				return null;
				}
			System.out.print("take chems?:");
			line = br.readLine();
			boolean chems = line.toLowerCase().equals("yes") ? true : false;
			System.out.print("take escort?:");
			line = br.readLine();
			boolean escort = line.toLowerCase().equals("yes") ? true : false;
			System.out.print("are we done after this?:");
			line = br.readLine();
			done = line.toLowerCase().equals("yes") ? true : false; 
			return new Move(this,road, current, dest, escort, chems);
		} catch (IOException e) {
			// Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public boolean isDone() {
		
		return done;
	}
public City getGoal() {
		
		return goal;
	}

@Override
public void setCity(City to) {
	current = to;
	
}
}
